
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>KingBase · GitBook笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="chenjiebin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="polardb.html" />
    
    
    <link rel="prev" href="redis.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../document/kubernetes/kubernetes.html">
            
                <a href="../document/kubernetes/kubernetes.html">
            
                    
                    Kubernetes英文教程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../document/kubernetes/kubernetes.html">
            
                <a href="../document/kubernetes/kubernetes.html#concepts">
            
                    
                    Kubernetes Concepts
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1.1" data-path="../document/kubernetes/concepts/overview.html">
            
                <a href="../document/kubernetes/concepts/overview.html">
            
                    
                    Kubernetes Overview
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.2" data-path="../document/kubernetes/concepts/components.html">
            
                <a href="../document/kubernetes/concepts/components.html">
            
                    
                    Kubernetes Components
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.3" data-path="../document/kubernetes/concepts/nodes.html">
            
                <a href="../document/kubernetes/concepts/nodes.html">
            
                    
                    Kubernetes Nodes
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../document/kubernetes/kubernetes.html">
            
                <a href="../document/kubernetes/kubernetes.html#tutorial">
            
                    
                    Kubernetes Tutorial
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.2.1" data-path="../document/kubernetes/tutorial/kubernetes-basics.html">
            
                <a href="../document/kubernetes/tutorial/kubernetes-basics.html">
            
                    
                    Kubernetes Basics
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../java/java.html">
            
                <a href="../java/java.html">
            
                    
                    Java基础知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../java/java-summary.html">
            
                <a href="../java/java-summary.html">
            
                    
                    Java_Summary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../java/java-jvm.html">
            
                <a href="../java/java-jvm.html">
            
                    
                    Java_JVM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../java/effectiveJava.html">
            
                <a href="../java/effectiveJava.html">
            
                    
                    effectiveJava
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../java/design-pattern.html">
            
                <a href="../java/design-pattern.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../java/JavaTest.html">
            
                <a href="../java/JavaTest.html">
            
                    
                    JavaTest
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../java/myframe.html">
            
                <a href="../java/myframe.html">
            
                    
                    MyFrame
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="database.html">
            
                <a href="database.html">
            
                    
                    数据库基础知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="mysql.html">
            
                <a href="mysql.html">
            
                    
                    MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="redis.html">
            
                <a href="redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.3" data-path="kingbase.html">
            
                <a href="kingbase.html">
            
                    
                    KingBase
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="polardb.html">
            
                <a href="polardb.html">
            
                    
                    PolarDB
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../system/system.html">
            
                <a href="../system/system.html">
            
                    
                    环境配置工具
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../system/nodejs.html">
            
                <a href="../system/nodejs.html">
            
                    
                    Node.js
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../system/gitbook.html">
            
                <a href="../system/gitbook.html">
            
                    
                    Gitbook
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../system/linux.html">
            
                <a href="../system/linux.html">
            
                    
                    Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../system/kylin.html">
            
                <a href="../system/kylin.html">
            
                    
                    麒麟系统
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../tool/tool.html">
            
                <a href="../tool/tool.html">
            
                    
                    开发工具介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../tool/docker.html">
            
                <a href="../tool/docker.html">
            
                    
                    Docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../tool/idea.html">
            
                <a href="../tool/idea.html">
            
                    
                    Idea
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../tool/maven.html">
            
                <a href="../tool/maven.html">
            
                    
                    Maven
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../tool/gradle.html">
            
                <a href="../tool/gradle.html">
            
                    
                    Gradle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../framework/kubernate.html">
            
                <a href="../framework/kubernate.html">
            
                    
                    Kubernetes
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >KingBase</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#kingbase-&#x5B89;&#x88C5;"><b>1. </b>Kingbase &#x5B89;&#x88C5;</a></li><li><span class="title-icon "></span><a href="#kingbase-&#x7BA1;&#x7406;"><b>2. </b>Kingbase &#x7BA1;&#x7406;</a></li><ul><li><span class="title-icon "></span><a href="#&#x7528;&#x6237;&#x7C7B;&#x578B;"><b>2.1. </b>&#x7528;&#x6237;&#x7C7B;&#x578B;</a></li><li><span class="title-icon "></span><a href="#sql-&#x8BED;&#x53E5;"><b>2.2. </b>SQL &#x8BED;&#x53E5;</a></li></ul><li><span class="title-icon "></span><a href="#kingbase-&#x5EF6;&#x671F;"><b>3. </b>Kingbase &#x5EF6;&#x671F;</a></li></ul></div><a href="#kingbase-&#x5B89;&#x88C5;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="kingbase-&#x5B89;&#x88C5;"><a name="kingbase-&#x5B89;&#x88C5;" class="anchor-navigation-ex-anchor" href="#kingbase-&#x5B89;&#x88C5;"><i class="fa fa-link" aria-hidden="true"></i></a>1. Kingbase &#x5B89;&#x88C5;</h1>
<blockquote>
<p>&#x4E0B;&#x8F7D;&#x5730;&#x5740;</p>
</blockquote>
<p><a href="https://www.kingbase.com.cn/rjcxxz/index.htm" target="_blank">https://www.kingbase.com.cn/rjcxxz/index.htm</a></p>
<blockquote>
<p>&#x6821;&#x9A8C;md5&#x503C;</p>
</blockquote>
<pre class="language-"><code class="lang-shell">certutil <span class="token parameter variable">-hashfile</span> ./KingbaseES_V008R006C007B0012_Win64_install.iso MD5
</code></pre>
<blockquote>
<p>&#x5B89;&#x88C5;&#x76EE;&#x5F55;</p>
</blockquote>
<p><code>D:\Program Files\Application\Kingbase\ES\V8</code></p>
<blockquote>
<p>&#x6570;&#x636E;&#x76EE;&#x5F55;</p>
</blockquote>
<p><code>D:\Program Files\Application\Kingbase\ES\V8\data</code></p>
<blockquote>
<p>&#x5B89;&#x88C5;&#x8FC7;&#x7A0B;</p>
</blockquote>
<ul>
<li>&#x542F;&#x52A8;&#x5B89;&#x88C5;&#x7A0B;&#x5E8F;</li>
<li>&#x9009;&#x62E9;&#x3010;&#x7B80;&#x4F53;&#x4E2D;&#x6587;&#x3011;</li>
<li>&#x9009;&#x62E9;&#x3010;&#x5B89;&#x88C5;&#x65B0;&#x7684;&#x5B9E;&#x4F8B;&#x3011;</li>
<li>&#x63A5;&#x53D7;&#x3010;&#x8BB8;&#x53EF;&#x534F;&#x8BAE;&#x3011;</li>
<li>&#x9009;&#x62E9;&#x3010;&#x5B8C;&#x5168;&#x5B89;&#x88C5;&#x3011;</li>
<li>&#x9009;&#x62E9;&#x3010;&#x6388;&#x6743;&#x6587;&#x4EF6;&#x3011;</li>
<li>&#x9009;&#x62E9;&#x5B89;&#x88C5;&#x8DEF;&#x5F84;</li>
<li>&#x9884;&#x5B89;&#x88C5;&#x6458;&#x8981;</li>
<li>&#x5B89;&#x88C5; KingbaseES</li>
<li>&#x521D;&#x59CB;&#x5316;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;&#x5B89;&#x88C5;&#x76EE;&#x5F55;&#x4E0B;&#x7684; data &#x76EE;&#x5F55;</li>
<li>&#x5B89;&#x88C5;&#x5B8C;&#x6210;</li>
</ul>
<blockquote>
<p>&#x6570;&#x636E;&#x5E93;</p>
</blockquote>
<p>&#x670D;&#x52A1;&#x7AEF;&#x53E3;&#x53F7;&#xFF1A;54321</p>
<p>&#x7BA1;&#x7406;&#x5458;/&#x5BC6;&#x7801;&#xFF1A;system/system</p>
<p>&#x5B57;&#x7B26;&#x96C6;&#xFF1A;GBK</p>
<h1 id="kingbase-&#x7BA1;&#x7406;"><a name="kingbase-&#x7BA1;&#x7406;" class="anchor-navigation-ex-anchor" href="#kingbase-&#x7BA1;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>2. Kingbase &#x7BA1;&#x7406;</h1>
<h2 id="&#x7528;&#x6237;&#x7C7B;&#x578B;"><a name="&#x7528;&#x6237;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x7528;&#x6237;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>2.1. &#x7528;&#x6237;&#x7C7B;&#x578B;</h2>
<ul>
<li><p>&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x5458;</p>
<p>&#x81F3;&#x5C11;&#x9700;&#x8981;&#x4E00;&#x4F4D;&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x5458;</p>
</li>
<li><p>&#x5B89;&#x5168;&#x7BA1;&#x7406;&#x5458;</p>
</li>
<li><p>&#x5E94;&#x7528;&#x5F00;&#x53D1;&#x4EBA;&#x5458;</p>
</li>
<li><p>&#x6570;&#x636E;&#x5E93;&#x7528;&#x6237;</p>
</li>
</ul>
<h2 id="sql-&#x8BED;&#x53E5;"><a name="sql-&#x8BED;&#x53E5;" class="anchor-navigation-ex-anchor" href="#sql-&#x8BED;&#x53E5;"><i class="fa fa-link" aria-hidden="true"></i></a>2.2. SQL &#x8BED;&#x53E5;</h2>
<p>Ksql &#x662F; KingbaseES &#x6570;&#x636E;&#x5E93;&#x7684;&#x4E3B;&#x8981;&#x547D;&#x4EE4;&#x884C;&#x754C;&#x9762;</p>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528; Ksql &#x8BBE;&#x7F6E;&#x6570;&#x636E;&#x5E93;&#x521D;&#x59CB;&#x5316;&#x53C2;&#x6570;&#x3001;&#x521B;&#x5EFA;&#x548C;&#x7BA1;&#x7406;&#x7528;&#x6237;&#x3001;&#x521B;&#x5EFA;&#x548C;&#x66F4;&#x6539;&#x6570;&#x636E;&#x5E93;&#x5BF9;&#x8C61;&#x3001;&#x63D2;&#x5165;&#x548C;&#x66F4;&#x65B0;&#x6570;&#x636E;&#x3001;&#x8FD0;&#x884C;SQL&#x67E5;&#x8BE2;</p>
<pre class="language-"><code class="lang-shell"><span class="token comment"># &#x5173;&#x95ED;&#x6570;&#x636E;&#x5E93;&#xFF08;cd %KINGBASE_HOME%&#xFF09;</span>
sys_ctl <span class="token parameter variable">-D</span> ./data stop

<span class="token comment"># &#x542F;&#x52A8;&#x5B9E;&#x4F8B;&#xFF08;cd %KINGBASE_HOME%&#xFF09;</span>
sys_ctl <span class="token parameter variable">-D</span> .<span class="token punctuation">\</span>data start

<span class="token comment"># &#x91CD;&#x542F;&#x5B9E;&#x4F8B;&#xFF08;cd %KINGBASE_HOME%&#xFF09;</span>
sys_ctl <span class="token parameter variable">-D</span> .<span class="token punctuation">\</span>data restart

<span class="token comment"># &#x4F7F;&#x7528; ksql &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;</span>
ksql <span class="token parameter variable">-U</span> username <span class="token parameter variable">-d</span> dbname <span class="token parameter variable">-p</span> port
ksql <span class="token parameter variable">-h</span> <span class="token function">hostname</span> <span class="token parameter variable">-U</span> username <span class="token parameter variable">-d</span> dbname <span class="token parameter variable">-p</span> port
ksql <span class="token parameter variable">-h</span> localhost <span class="token parameter variable">-U</span> system <span class="token parameter variable">-d</span> emergency <span class="token parameter variable">-p</span> <span class="token number">54321</span>

<span class="token comment"># &#x67E5;&#x770B;&#x7248;&#x672C;</span>
ksql <span class="token parameter variable">-V</span>
<span class="token keyword">select</span> version<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment"># &#x67E5;&#x770B;&#x8FDE;&#x63A5;&#x6570;</span>
<span class="token keyword">select</span> connections<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment"># &#x67E5;&#x770B;license&#x6709;&#x6548;&#x671F;</span>
<span class="token keyword">select</span> GET_LICENSE_VALIDDAYS<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment"># &#x67E5;&#x770B;&#x6240;&#x6709;&#x7528;&#x6237;</span>
<span class="token punctuation">\</span>du

<span class="token comment"># &#x521B;&#x5EFA;&#x7528;&#x6237;</span>
create user &#x7528;&#x6237;&#x540D; with superuser password <span class="token string">&apos;&#x5BC6;&#x7801;&apos;</span><span class="token punctuation">;</span>
create user &#x7528;&#x6237;&#x540D; with password <span class="token string">&apos;&#x5BC6;&#x7801;&apos;</span><span class="token punctuation">;</span>

<span class="token comment"># &#x5220;&#x9664;&#x7528;&#x6237;</span>
drop user &#x7528;&#x6237;&#x540D;<span class="token punctuation">;</span>

<span class="token comment"># &#x4FEE;&#x6539;&#x7BA1;&#x7406;&#x5458;&#x5BC6;&#x7801;</span>
alter user system password <span class="token string">&apos;12345678ab!&apos;</span><span class="token punctuation">;</span>

<span class="token comment"># &#x67E5;&#x770B;&#x6240;&#x6709;&#x6570;&#x636E;&#x5E93;&#x5217;&#x8868;</span>
<span class="token punctuation">\</span>l

<span class="token comment"># &#x521B;&#x5EFA;&#x6570;&#x636E;&#x5E93;</span>
create database &#x6570;&#x636E;&#x5E93;&#x540D;<span class="token punctuation">;</span>
create database &#x6570;&#x636E;&#x5E93;&#x540D; owner &#x7528;&#x6237;&#x540D;<span class="token punctuation">;</span>
grant all on database &#x6570;&#x636E;&#x5E93;&#x540D; to &#x7528;&#x6237;&#x540D;<span class="token punctuation">;</span>

create database testdb with template template0 encoding <span class="token string">&apos;GBK&apos;</span> lc_collate <span class="token string">&apos;zh_CN.GBK&apos;</span> lc_ctype <span class="token string">&apos;zh_CN.GBK&apos;</span><span class="token punctuation">;</span>

<span class="token comment"># &#x5220;&#x9664;&#x6570;&#x636E;&#x5E93;</span>
drop database &#x6570;&#x636E;&#x5E93;&#x540D;<span class="token punctuation">;</span>

<span class="token comment"># &#x67E5;&#x770B;&#x6700;&#x5927;&#x8FDE;&#x63A5;&#x6570;</span>
show max_connections<span class="token punctuation">;</span>

<span class="token comment"># &#x67E5;&#x770B;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x8868;</span>
<span class="token punctuation">\</span>d

<span class="token comment"># &#x67E5;&#x770B;&#x7F16;&#x7801;</span>
show server_encoding<span class="token punctuation">;</span>
show client_encoding<span class="token punctuation">;</span>

<span class="token builtin class-name">set</span> client_encoding to <span class="token string">&apos;UTF8&apos;</span><span class="token punctuation">;</span>

<span class="token comment"># &#x6DFB;&#x52A0;&#x5B57;&#x6BB5;</span>
alter table emergency.earthquake_task_result <span class="token function">add</span> <span class="token function">column</span> origin_id varchar<span class="token punctuation">(</span><span class="token number">64</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment"># &#x4FEE;&#x6539;&#x5B57;&#x6BB5;</span>
alter table emergency.disaster_task alter <span class="token function">column</span> disaster_type <span class="token builtin class-name">type</span> varchar<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment"># &#x6DFB;&#x52A0;&#x6CE8;&#x91CA;</span>
comment on <span class="token function">column</span> emergency.earthquake_task_result.origin_id is <span class="token string">&apos;&#x5730;&#x9707;&#x4FE1;&#x606F;&#x5361;ID&apos;</span><span class="token punctuation">;</span>

<span class="token comment"># &#x56DE;&#x6536;&#x7A7A;&#x95F4;</span>
vacuum emergency.task_log<span class="token punctuation">;</span>

<span class="token comment"># &#x62FC;&#x63A5;&#x5355;&#x4E2A;&#x5B57;&#x6BB5;&#x7684;&#x5C5E;&#x6027;&#x503C;</span>
<span class="token keyword">select</span> string_agg<span class="token punctuation">(</span>city_id, <span class="token string">&apos;,&apos;</span><span class="token punctuation">)</span> from emergency.t_city<span class="token punctuation">;</span>

<span class="token comment"># &#x8FDE;&#x63A5;&#x591A;&#x4E2A;&#x5B57;&#x6BB5;&#x5C5E;&#x6027;&#x503C;</span>
<span class="token keyword">select</span> concat_ws<span class="token punctuation">(</span><span class="token string">&apos;:&apos;</span>, city_id, city_name<span class="token punctuation">)</span> from emergency.t_city<span class="token punctuation">;</span>

<span class="token comment"># &#x8FDE;&#x63A5;&#x591A;&#x4E2A;&#x5B57;&#x6BB5;&#x5C5E;&#x6027;&#x503C;&#xFF0C;&#x518D;&#x62FC;&#x63A5;</span>
<span class="token keyword">select</span> string_agg<span class="token punctuation">(</span>concat_ws<span class="token punctuation">(</span><span class="token string">&apos;:&apos;</span>, city_id, city_name<span class="token punctuation">)</span>, <span class="token string">&apos;,&apos;</span><span class="token punctuation">)</span> from emergency.t_city<span class="token punctuation">;</span>

<span class="token comment"># &#x67E5;&#x8BE2;emergency&#x4E0B;&#x7684;&#x8868;&#x540D;&#x79F0;</span>
<span class="token keyword">select</span> distinct table_name from information_schema.tables where <span class="token assign-left variable">table_schema</span><span class="token operator">=</span><span class="token string">&apos;emergency&apos;</span><span class="token punctuation">;</span>

<span class="token comment"># &#x65E5;&#x671F;&#x64CD;&#x4F5C;</span>
<span class="token keyword">select</span> <span class="token string">&apos;2023-09-01&apos;</span>::date<span class="token punctuation">;</span>
<span class="token keyword">select</span> <span class="token string">&apos;20230901&apos;</span>::date<span class="token punctuation">;</span>
<span class="token keyword">select</span> <span class="token string">&apos;20230901&apos;</span>::date - interval <span class="token string">&apos;1 days&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">select</span> to_char<span class="token punctuation">(</span><span class="token string">&apos;20230901&apos;</span>::date - interval <span class="token string">&apos;1 days&apos;</span>, <span class="token string">&apos;yyyyMMdd&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment"># &#x67E5;&#x770B;&#x5B57;&#x6BB5;&#x5907;&#x6CE8;</span>
<span class="token keyword">select</span> a.attname column_name, b.description
from sys_attribute a, sys_description b
where <span class="token assign-left variable">a.attrelid</span><span class="token operator">=</span>b.objoid and <span class="token assign-left variable">a.attnum</span><span class="token operator">=</span>b.objsubid
  and a.attrelid <span class="token keyword">in</span> <span class="token punctuation">(</span>select oid from sys_class where <span class="token assign-left variable">relname</span><span class="token operator">=</span><span class="token string">&apos;mine_data&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">select</span> a.relname class_name, b.attname column_name, c.description
from sys_class a, sys_attribute b, sys_description c
where <span class="token assign-left variable">a.oid</span><span class="token operator">=</span>b.attrelid and <span class="token assign-left variable">b.attrelid</span><span class="token operator">=</span>c.objoid and <span class="token assign-left variable">b.attnum</span><span class="token operator">=</span>c.objsubid
  and a.relname <span class="token keyword">in</span> <span class="token punctuation">(</span><span class="token string">&apos;mine_data&apos;</span>, <span class="token string">&apos;mine_info&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">select</span> a.relname class_name, b.attname column_name, d.typname column_type, b.attnotnull column_notnull, <span class="token string">&apos;&apos;</span> column_default, c.description column_comment
from sys_class a, pg_type d, sys_attribute b
    left <span class="token function">join</span> sys_description c on <span class="token assign-left variable">b.attrelid</span><span class="token operator">=</span>c.objoid and <span class="token assign-left variable">b.attnum</span><span class="token operator">=</span>c.objsubid
where <span class="token assign-left variable">a.oid</span><span class="token operator">=</span>b.attrelid and <span class="token assign-left variable">b.atttypid</span><span class="token operator">=</span>d.oid and b.attoptions is not null
  and a.relname <span class="token operator">=</span> <span class="token string">&apos;disaster_task&apos;</span><span class="token punctuation">;</span>

<span class="token comment"># &#x7528;&#x67E5;&#x8BE2;&#x7684;&#x6570;&#x636E;&#x521B;&#x5EFA;&#x8868;&#x5E76;&#x590D;&#x5236;&#x6570;&#x636E;</span>
create table demo_copy as <span class="token keyword">select</span> id, name, value from demo

<span class="token comment"># &#x4FEE;&#x6539;&#x5E8F;&#x5217;&#x5F53;&#x524D;&#x503C;</span>
<span class="token keyword">select</span> setval<span class="token punctuation">(</span><span class="token string">&apos;emergency.disaster_task_id_seq&apos;</span>, <span class="token number">20</span>, <span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">select</span> currval<span class="token punctuation">(</span><span class="token string">&apos;emergency.disaster_task_id_seq&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">select</span> nextval<span class="token punctuation">(</span><span class="token string">&apos;emergency.disaster_task_id_seq&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment"># &#x4FEE;&#x6539; group by &#x6A21;&#x5F0F;</span>
Kingbase<span class="token punctuation">\</span>ES<span class="token punctuation">\</span>V8<span class="token punctuation">\</span>data<span class="token punctuation">\</span>kingbase.auto.conf
<span class="token comment"># &#x6DFB;&#x52A0;&#x5185;&#x5BB9;</span>
sql_mode <span class="token operator">=</span> <span class="token string">&apos;&apos;</span>

<span class="token comment"># &#x8BBE;&#x7F6E;&#x53E3;&#x4EE4;&#x5BC6;&#x6587;</span>
<span class="token comment"># &#x672C;&#x5730;&#x8BBE;&#x7F6E;&#x652F;&#x6301;&#x514D;&#x5BC6;&#x767B;&#x9646;&#xFF1A;&#x4FEE;&#x6539;/data/sys_hba.conf&#x6587;&#x4EF6;&#x4E2D; host all all 127.0.0.1/32 scram-sha-256 &#x4E2D;&#x7684; scram-sha-256 &#x4E3A;trust&#xFF0C;&#x5E76;&#x91CD;&#x542F;&#x670D;&#x52A1;</span>
sys_encpwd
  <span class="token parameter variable">-H</span> <span class="token parameter variable">--hostname</span><span class="token operator">=</span>    &#x670D;&#x52A1;&#x5668;&#x4E3B;&#x673A;&#x5730;&#x5740;
  <span class="token parameter variable">-P</span> <span class="token parameter variable">--portnum</span><span class="token operator">=</span>     &#x670D;&#x52A1;&#x5668;&#x4E3B;&#x673A;&#x7AEF;&#x53E3;
  <span class="token parameter variable">-D</span> <span class="token parameter variable">--database</span><span class="token operator">=</span>    &#x6570;&#x636E;&#x5E93;&#x540D;&#x79F0;
  <span class="token parameter variable">-U</span> <span class="token parameter variable">--user</span><span class="token operator">=</span>        &#x6570;&#x636E;&#x5E93;&#x7528;&#x6237;&#x540D;
  <span class="token parameter variable">-W</span> <span class="token parameter variable">--password</span><span class="token operator">=</span>    &#x6570;&#x636E;&#x5E93;&#x5BC6;&#x7801;

<span class="token comment"># &#x5907;&#x4EFD;&#x5B9A;&#x4E49;&#x548C;&#x6570;&#x636E;</span>
sys_dump <span class="token punctuation">[</span>connection-option<span class="token punctuation">..</span>.<span class="token punctuation">]</span> <span class="token punctuation">[</span>option<span class="token punctuation">..</span>.<span class="token punctuation">]</span> <span class="token punctuation">[</span>dbname<span class="token punctuation">]</span>
  dbname            &#x6570;&#x636E;&#x5E93;&#x540D;&#x79F0;
  <span class="token parameter variable">-a</span> --data-only    &#x53EA;&#x5907;&#x4EFD;&#x6570;&#x636E;
  <span class="token parameter variable">-s</span> --schema-only  &#x53EA;&#x5907;&#x4EFD;&#x5B9A;&#x4E49;
  <span class="token parameter variable">-b</span> <span class="token parameter variable">--blobs</span>        &#x8F6C;&#x50A8;&#x4E2D;&#x5305;&#x62EC;&#x5927;&#x5BF9;&#x8C61; &#x9ED8;&#x8BA4;
  <span class="token parameter variable">-B</span> --no-blobs     &#x6392;&#x9664;&#x8F6C;&#x50A8;&#x4E2D;&#x5927;&#x5BF9;&#x8C61;
  <span class="token parameter variable">-c</span> <span class="token parameter variable">--clean</span>        &#x6DFB;&#x52A0;&#x5220;&#x9664;&#x8868;&#x547D;&#x4EE4;
  <span class="token parameter variable">-t</span> pattern        &#x540D;&#x79F0;&#x5339;&#x914D;
  <span class="token parameter variable">-T</span> pattern        &#x540D;&#x79F0;&#x6392;&#x9664;
  <span class="token parameter variable">-n</span> <span class="token parameter variable">--pattern</span>      &#x6B63;&#x5219;&#x5339;&#x914D;
  <span class="token parameter variable">-N</span> <span class="token parameter variable">--pattern</span>      &#x6B63;&#x5219;&#x6392;&#x9664;
  <span class="token comment"># &#x63A7;&#x5236;&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x53C2;&#x6570;</span>
  <span class="token parameter variable">-d</span> dbname <span class="token parameter variable">--dbname</span><span class="token operator">=</span>dbname &#x6570;&#x636E;&#x5E93;&#x540D;&#x79F0;
  <span class="token parameter variable">-h</span> <span class="token function">host</span> <span class="token parameter variable">--host</span><span class="token operator">=</span>host       &#x670D;&#x52A1;&#x5668;&#x4E3B;&#x673A;&#x5730;&#x5740;
  <span class="token parameter variable">-p</span> port <span class="token parameter variable">--port</span><span class="token operator">=</span>port       &#x670D;&#x52A1;&#x5668;&#x4E3B;&#x673A;&#x7AEF;&#x53E3;
  <span class="token parameter variable">-U</span> username <span class="token parameter variable">--username</span><span class="token operator">=</span>username &#x6570;&#x636E;&#x5E93;&#x7528;&#x6237;&#x540D;

<span class="token comment"># &#x975E;&#x7A7A;&#x5224;&#x65AD;</span>
<span class="token keyword">select</span> coalesce<span class="token punctuation">(</span>null, <span class="token string">&apos;-&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x6570;&#x636E;&#x52A0;&#x8F7D;&#x5DE5;&#x5177;&#xFF1A;&#x53C2;&#x8003;&#x624B;&#x518C;&#x4E2D;&#x7684;sys_bulkload</p>
<p>&#x6570;&#x636E;&#x5BFC;&#x51FA;&#x5BFC;&#x5165;&#x5DE5;&#x5177;&#xFF1A;sys_dump&#x3001;sys_restore&#x3001;exp/imp&#x5DE5;&#x5177;</p>
<h1 id="kingbase-&#x5EF6;&#x671F;"><a name="kingbase-&#x5EF6;&#x671F;" class="anchor-navigation-ex-anchor" href="#kingbase-&#x5EF6;&#x671F;"><i class="fa fa-link" aria-hidden="true"></i></a>3. Kingbase &#x5EF6;&#x671F;</h1>
<pre class="language-"><code class="lang-bash"><span class="token builtin class-name">cd</span> /data/kingbase/ES/V8/KESRealPro/V008R006C007B0012
<span class="token function">mv</span> licese.dat license.dat.bak
<span class="token function">mv</span> license_4392_0.dat license.dat
<span class="token function">chown</span> kingbase:kingbase license.data
<span class="token function">sudo</span> systemctl start kingbase
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="redis.html" class="navigation navigation-prev " aria-label="Previous page: Redis">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="polardb.html" class="navigation navigation-next " aria-label="Next page: PolarDB">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"KingBase","level":"1.4.3","depth":2,"next":{"title":"PolarDB","level":"1.4.4","depth":2,"path":"markdown/database/polardb.md","ref":"markdown/database/polardb.md","articles":[]},"previous":{"title":"Redis","level":"1.4.2","depth":2,"path":"markdown/database/redis.md","ref":"markdown/database/redis.md","articles":[]},"dir":"ltr"},"config":{"plugins":["theme-default","prism","-highlight","search-pro","-search","-lunr","expandable-chapters-small","splitter","-sharing","anchor-navigation-ex","code"],"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"},"pluginsConfig":{"prism":{},"search-pro":{},"expandable-chapters-small":{},"splitter":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"showLevel":false,"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"}}},"theme":"default","author":"chenjiebin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pluginConfig":{"prism":{"css":["prismjs/themes/prism-solarizedlight.css"]},"anchor-navigation-ex":{"showLevel":true},"theme-default":{"toggleMenu":false}},"variables":{},"title":"GitBook笔记","gitbook":"*","description":"学习笔记，包含前后端基础知识及框架的学习笔记"},"file":{"path":"markdown/database/kingbase.md","mtime":"2024-02-22T03:06:30.011Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2024-02-28T09:32:04.838Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

